<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue实现计数器功能</title>
</head>
<body>

  <div class="id">
    <h3>当前计数：{{ count }}</h3>
    <button @click="increment">+1</button>
    <button @click="decrement">-1</button>
  </div>
  <script src="../lib/vue.js"></script>
  <script>
    const app = Vue.createApp({
      // template: `
      //   <h2>当前计数: {{count}}</h2>
      //   <button @click="increment">+1</button>
      //   <button @click="decrement">-1</button>
      // `,
      data() {
        return {
          count: 0
        }
      },
      methods: {
        increment() {
          this.count++
        },
        decrement() {
          this.count--
        }
      }
    })
    app.mount('.id')

  </script>

  
</body>
</html>